<template>
    <div>
        <h2>科室添加</h2>
         <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">科室名称</td>
                    <td>
                        <input type="text" v-model="info.KeName"></input>
                    </td>
                </tr>
                <tr>
                    <td align="right">科室人数</td>
                    <td>
                        <input type="text" v-model="info.KeNum"></input>
                    </td>
                </tr>
                <tr>
                    <td align="right">科室介绍</td>
                    <td>
                       <textarea rows="4" cols="40" v-model="info.KeContent"></textarea>
                    </td>
                </tr>
                <tr>
                    <td align="right">创建时间</td>
                    <td>
                        <input type="date" v-model="info.CreateTime"></input>
                    </td>
                </tr>

                <tr>
                    <td align="right"></td>
                    <td>
                        <input type="button" value="确定" class="btn btn-primary" @click="ok"></input>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from "axios";
import moment from "moment";
import {ref,reactive,onMounted} from "vue"
import {useRoute,useRouter} from "vue-router"
import {useStore} from "@/stores/user"

const route = useRoute();
const router = useRouter();
const abc = useStore();

let info:any = reactive({
  KeName: '',
  KeNum: '',
  KeContent: '',
  CreateTime: '',
})



const ok=()=>{
    if(info.KeName==""){
        alert('科室名称不能为空');
        return
    }
    if(info.KeNum==""){
        alert('请输入人数');
        return
    }
    if(info.KeContent==""){
        alert('介绍不能为空');
        return
    }
     if(info.CreateTime==""){
        alert('请选择时间');
        return
    }
    axios({
        url:'/api/YeHotels/AddKeRoom',
        method:'post',
        data:info
    })
    .then(res=>{
        console.log(res);
        if(res.data==-1){
            alert('已有科室 请重新添加');
            return;
        }
        if(res.data>0){
            alert('添加成功');
            router.push("/keRoomShow")
            return;
        }
        alert('添加失败');
        return;
    })
    .catch(err=>{
        console.log(err);
        
    })
}


</script>

<style scoped>

</style>